#! /usr/bin/env python3

from typing import List


def top_k(nums: List[int], k: int) -> List[int]:
    """
    指定一个数组，返回出现高频次的若干数字
    """
    result = [ (k, nums.count(k)) for k in set(nums) ]
    result.sort(key=lambda x: x[1], reverse=True)
    print(result)
    print([ i[0] for i in result[:k] ])

top_k([1, 1, 1, 2, 2, 3], 2)

